package com.fanshe;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class ReflectDemo3 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        Class<?> c = Class.forName("com.fanshe.Student");
        Constructor<?> con = c.getDeclaredConstructor(String.class);
        // 使用私有构造方法创建对象--暴力反射,值为true，取消访问检查
        con.setAccessible(true);
        Object obj = con.newInstance("zhouwei");
        System.out.println(obj);

    }
}
